<template>
  <div>
    <!-- 添加或修改部门对话框 -->
    <el-dialog  title="修改" :visible.sync="open" width="880px" append-to-body  class="dia-style">
   <el-row :gutter="15">
      <el-form
        ref="elForm"
        :model="formData"
        :rules="rules"
        size="medium"
        label-width="150px"
        label-position="left"
      >
        <el-col :span="20">
          <el-form-item label="指标属性名称" prop="field101">
            <el-input
              v-model="formData.field101"
              placeholder="请输入"
              clearable
              :style="{ width: '100%' }"
            >
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="20">
          <el-form-item label="指标属性编码" prop="field102">
            <el-input
              v-model="formData.field102"
              placeholder="请输入"
              clearable
              :style="{ width: '100%' }"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
              <el-form-item label="子集名称及代码">
         <el-button @click="AddClick" icon="el-icon-plus" size="small" style="width: 108px;">添加</el-button>
          </el-form-item>
      
        </el-col>
        <el-col :span="24">
          <el-table
          stripe
            :data="tableData"
            :header-cell-style="{ background: '#F3F5FC' }"
            style="width: 100%"     

          >
            <el-table-column
              prop="index"
              label="序号"
              width="80"
              align="center"
            >
            </el-table-column>
            <el-table-column prop="name" label="名称" width="240">
              <template slot-scope="scope">
                <el-input v-model="scope.row.name"></el-input>
              </template>
            </el-table-column>
            <el-table-column prop="code" label="代码" width="240">
              <template slot-scope="scope">
                <el-input
                  v-model="scope.row.code"
                  :disabled="scope.row.code != ''"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column prop="operate" label="操作" align="center">
              <template slot-scope="scope">
                <span
                  style="color: #4B6EEF;"
                  v-if="scope.row.operate == ''"
                  @click.stop="MoveClick"
                  >删 除</span
                >
                <span v-else>{{ scope.row.operate }}</span>
              </template>
            </el-table-column>
          </el-table>
        </el-col>
      </el-form>
    </el-row>
      <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitForm">保 存</el-button>
        <el-button @click="cancel">取 消</el-button>
      
      </div>
    </el-dialog>

  </div>
</template>
<script>
export default {
  components: {},
props: ['tableData'],
  data() {
    return {
      // 是否显示遮罩层
      open:false,

      // 表单的数据
      formData: {
        field101: undefined,
        field102: undefined,
        field103: undefined,
        field104: undefined,
      },
      rules: {
        field101: [
          {
            required: true,
            message: "是否超期",
            trigger: "blur",
          },
        ],
        field102: [],
        field103: [
          {
            required: true,
            message: "请输入单行文本",
            trigger: "blur",
          },
        ],
        field104: [
          {
            required: true,
            message: "请输入单行文本",
            trigger: "blur",
          },
        ],
      },
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    // 增加弹框数据
    AddClick() {
      const arr = {
        index: this.tableData[this.tableData.length - 1].index + 1,
        name: "",
        code: "",
        operate: "",
      };
      this.tableData.push(arr);
    },
    MoveClick() {
      this.tableData.pop();
    },
    submitForm() {
      this.$refs["elForm"].validate((valid) => {
        if (!valid) return;
        // TODO 提交表单
      });
    },
    resetForm() {
      this.$refs["elForm"].resetFields();
    },
        // 取消按钮
    cancel() {
    this.open = false;
      this.resetForm();
    },
  },
};
</script>
<style lang="scss" scoped>
.el-table{
  margin-top: 0;
}
</style>>
